package com.github.yoojia.flow.impl;

import com.github.yoojia.flow.Context;
import com.github.yoojia.flow.Event;
import com.github.yoojia.flow.support.VirtualScheduleDevice;

/**
 * @author 陈哈哈 yoojiachen@gmail.com
 */
public class SimulatePingDevice extends VirtualScheduleDevice {

    @Override
    protected void onScheduleTask() {
        final Event reply = getContext().requestEvent(
                Event.create(
                        0,
                        "PING".getBytes(),
                        Context.topicAppend(TOPIC, "PING"),
                        getAddress(),
                        getInitConfig().getString("pong.address"),
                        System.currentTimeMillis()));
        System.out.println("收到Reply: " + reply);
        System.out.println("收到Payload: " + reply.getTextPayload().getText());
    }
}
